package controller.link.battle;

import view.client.Console;
import model.Hearer;
import java.io.Serializable;
import model.game.Item;
import controller.Link;
import controller.link.RefreshGameData;
import model.Attendant;
import model.Server;

public class UseConsumable implements Link, Serializable {

    private Item item;

    public UseConsumable() {
    }

    public UseConsumable(Hearer h, Item i) {
        this.item = i;
        h.send((Link) this);
    }

    @Override
    public void serverUse(Server server, Attendant at) {
        if (server.getBattle(at) != null) {
            server.getBattle(at).useConsumable(at, item.getName());
            RefreshGameData rgd = new RefreshGameData();
            rgd.serverUse(server, at);
        }
    }

    @Override
    public void clientUse(Console console) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
